<template>
    <div>
        <my-header :title="'商品退款详情'"  :hasBacks="true" :goBack="goBack" :canteen ="true" :textAlign="'center'" v-if="isAll"></my-header>
        <my-header :title="'订单退款详情'"  :hasBacks="true" :goBack="goBack" :canteen ="true" :textAlign="'center'" v-else></my-header>
        <!-- 堂食订单的商品信息展示页面 -->
        <!-- <div style="flex:1;overflow-y:auto;overflow-x: hidden;" v-if="!isAll">
            <ul class="aui-list aui-media-list commodity_list subtotal_list" >
                <li class="aui-list-item baoguo-list-item baoguo-root" v-for="(list,indexs) in datas" :key='indexs'>
                    <div class="aui-media-list-item-inner">
                        <div class="aui-list-item-media" style="width:4.3125rem;height:4.3125rem ">
                            <div class="goodsTopShow" v-if="list.buyType == 2 || list.buyType == 3" :class="{goodsTopShowBackY:list.buyType == 2,goodsTopShowBackR:list.buyType == 3}">
                                {{list.buyType == 2?'加价购':'赠品'}}
                            </div>
                            <img v-lazy="list.goodsImg || goodsImg(list) || 'static/image/demo2.png'" alt="" />

                        </div>
                        <div class="aui-list-item-inner suggest" style="text-align: left;height: 5.3125rem;" >
                            <h3 >{{list.goodsname || list.goodsName}}</h3>
                            <p v-if="list.goodsSpec">规格：{{list.goodsSpec}}</p>
                            <p >数量：{{list.applyQuantity}}{{list.goodsSpec?"/"+list.goodsSpec:""}}</p>
                        </div>
                        <div class="subtotal" style="width: 38%;height:5.3125rem;">
                            <a style=" display: block;" >¥{{datas.realityAmount}}</a>
                        </div>
                    </div>
                </li> 
            </ul>
            <div style="margin-top:0.1rem;">
                <div style="background: #ffffff;text-align: left;padding-left:0.5rem; padding-top: 0.5rem;">
                    <span>退款件数：</span>
                    <span>{{datas.goodsList?datas.goodsList[0].applyQuantity+datas.goodsList[0].goodsSpec:""}}</span>
                </div>
                <div style="background: #ffffff;text-align: left;padding-left:0.5rem;padding-bottom: 0.5rem;">
                    <span>退款金额：</span>
                    <span>&#65509;{{datas.realityAmount}}</span>
                </div>
            </div>
        </div> -->
        <div style="flex:1;overflow-y:auto;overflow-x: hidden;">
            <ul class="aui-list aui-media-list commodity_list subtotal_list" >
                <li class="aui-list-item baoguo-list-item baoguo-root" v-for="(list,indexs) in datas" :key='indexs' >
                    <div class="aui-media-list-item-inner">
                        <div class="aui-list-item-media" style="width:4.3125rem;height:4.3125rem ">
                            <div class="goodsTopShow" v-if="list.goodsList[0].buyType == 2 || list.goodsList[0].buyType == 3" :class="{goodsTopShowBackY:list.goodsList[0].buyType == 2,goodsTopShowBackR:list.goodsList[0].buyType == 3}">
                                {{list.goodsList[0].buyType == 2?'加价购':'赠品'}}
                            </div>
                            <img v-lazy="list.goodsList[0].goodsImg || goodsImg(list.goodsList[0]) || 'static/image/demo2.png'" alt="" />

                        </div>
                        <div class="aui-list-item-inner suggest" style="text-align: left;height: 5.3125rem;" >
                            <h3 >{{list.goodsList[0].goodsname || list.goodsList[0].goodsName}}</h3>
                            <p v-if="list.goodsList[0].goodsSpec && list.serviceType == 2">规格：{{list.goodsList[0].goodsSpec}}</p>
                            <p v-if="list.goodsList[0].goodsSpec && list.serviceType == 1">规格：{{getUnit(list.goodsList[0].goodsSpec)}}</p>
                            <!-- <p >单价：¥{{getSingerPricely(list)}}</p> -->
                            <p >数量：{{list.goodsList[0].applyQuantity}}{{list.goodsList[0].goodsSpec?"/"+getUnit(list.goodsList[0].goodsSpec):""}}</p>
                        </div>
                        <div class="subtotal" style="width: 38%;height:5.3125rem;">
                            <!-- <a style=" display: block;" >¥{{getSingerPricesFood(list)}}</a> -->
                            <a style=" display: block;" >¥{{Number(list.goodsList[0].goodsApplyAmount).toFixed(2)}}</a>
                            <!-- <span style="display: inline-block;text-decoration:line-through;height:2.8rem;color: #ccc;font-size:0.5rem;"  v-if="compareMoneyFood(list)">¥{{getSingerPriceFood(list)}}</span> -->
                            <!-- <span style="display: inline-block;height:2.8rem;"  v-if="compareMoneysFood(list)">¥{{getSingerPriceFood(list)}}</span> -->
                        </div>
                    </div>
                </li> 
            </ul>
            <div style="margin-top:0.1rem;">
                <div style="background: #ffffff;text-align: left;padding-left:0.5rem; padding-top: 0.5rem;">
                    <span>退款件数：</span>
                    <span>{{datas ? detailNum():""}}</span>
                </div>
                <div style="background: #ffffff;text-align: left;padding-left:0.5rem;padding-bottom: 0.5rem;">
                    <span>退款金额：</span>
                    <span>&#65509;{{datas? detailPre():""}}</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import axios from 'axios';
    import MyHeader from "../header";



    export default {
        data() {
			return {
                datas: '',
                isAll:null,
                nums:0,
				
			}
        },
        components: {
			"my-header": MyHeader,
            
		},
        methods: {
            goBack(){
	    		window.history.back()
            },
            goodsImg(goodsItemData) {
	            if (goodsItemData && goodsItemData.urllist) {
	                if(goodsItemData.urllist.length) {
	                	for(let i = 0 ; i < goodsItemData.urllist.length; i++){
	                		if(goodsItemData.urllist[i].Imgurltype == 1){
	                			return goodsItemData.urllist[i].imgurl || "static/image/demo2.png";
	                		}
	                	}
	                } else {
	                    return "static/image/demo2.png";
	                }
	            } else {
	                return "static/image/demo2.png";
	            }
            },
            getSingerPricely(item){
	    		if(item.goodsType == 6){
	    			var str = '';
	    			if(item.mallUnit){
	    				str = (Number(item.wsprice) * Number(item.weighingbig)).toFixed(2)+'/'+item.mallUnit;
	    			}else{
	    				str = (Number(item.wsprice) * Number(item.weighingbig)).toFixed(2)
	    			}
	    			return str || '';
	    		}else{
	    			let str = Number(item.wsprice).toFixed(2) + '/' + item.goodsunit;
	    			return str || '';
	    		}
            },
            //比较价格堂食
			compareMoneyFood(item){
				// console.log("12345678910",this.getSingerPrices(item),this.getSingerPrice(item),this.getSingerPrices(item) - this.getSingerPrice(item))
				if(this.getSingerPricesFood(item) - this.getSingerPriceFood(item) < 0){
					return true
				}else{
					return false
				}
			},
			//比较价格堂食
			compareMoneysFood(item){
				// console.log("12345678910",this.getSingerPrices(item),this.getSingerPrice(item),this.getSingerPrices(item) - this.getSingerPrice(item))
				if(this.getSingerPricesFood(item) - this.getSingerPriceFood(item) == 0){
					return true
				}else{
					return false
				}
            },
            getSingerPriceFood(item){//堂食原价小计金额
	    		if(item.buyType == 1){
	    			var str = '';
	    			if(item.mallUnit){
	    				str = Number(item.totalMoney ).toFixed(2);
	    			}else{
	    				str = Number(item.totalMoney ).toFixed(2)
	    			}
	    			return str || '';
	    		}else{
	    			let str = Number(item.totalMoney ).toFixed(2);
	    			return str || '';
				}
			},
			getSingerPricesFood(item){//堂食优惠后的总金额
	    		if(item.buyType == 1){
	    			var str = '';
	    			if(item.mallUnit){
	    				str = Number(item.goodsDealPrice).toFixed(2);
	    			}else{
	    				str = Number(item.goodsDealPrice).toFixed(2)
	    			}
	    			return str || '';
	    		}else{
	    			let str = Number(item.goodsDealPrice ).toFixed(2);
	    			return str || '';
	    		}
            },
            detailNum(){
                let num = 0;
                this.datas && this.datas.forEach(element => {
                    element.goodsList.forEach(item=>{
                         num = num + item.applyQuantity
                    })
                   
                });
                return num;
            },
            detailPre(){
                let Pre = 0;
                this.datas && this.datas.forEach(element => {
                    Pre = Pre + element.realityAmount
                   
                });
                return Number(Pre).toFixed(2);
            },
            //处理规格里面的单位
            getUnit(items){
                // console.log(items.length,"/1/1/1/1/1/1/1/1/1/1/1/1/1/1/1/3")
                return items.substr(items.length-1);
            }
        },
        beforeDestroy() {
			
		
		},
        created() {
            this.isAll = this.$route.query.isAll;
            this.datas = this.$route.query.data;
            // console.log(this.isAll,"1222222222222222222222222",this.$route.query.data)
        }
    }


</script>
<style>
    .goodsTopShowBackY{
        background:#faa73c;
    }
    .goodsTopShowBackR{
        background: #EF5423;
    }
</style>
